﻿#if UNITY_EDITOR
using System;
using System.Collections.Generic;
/// <summary>
/// 编辑器枚举扩展
/// </summary>
public static class ESF_EnumExtend
{
    #region HasEnum 是否包含指定枚举
    /// <summary>
    /// 是否包含指定枚举
    /// </summary>
    /// <param name="_self">枚举值</param>
    /// <param name="_compare">比较值</param>
    /// <returns>true:包含,false:不包含</returns>
    public static bool HasEnum(this Enum _self, Enum _compare)
    {
        Type type = _self.GetType();
        bool isFlags = type.ESF_FirstAttribute<FlagsAttribute>() != null;
        bool result = false;
        int selfValue = Convert.ToInt32(_self);
        int compareValue = Convert.ToInt32(_compare);
        if (isFlags)
        {
            result = (selfValue & compareValue) == compareValue;
        }
        else
        {
            result = selfValue == compareValue;
        }
        return result;
    }
    #endregion

    #region 获得enESF_UnityFileExt的ESF_FileExtAttribute属性
    /// <summary>
    /// 获得enESF_UnityFileExt的ESF_FileExtAttribute属性
    /// </summary>
    /// <param name="_ext">后缀</param>
    /// <returns>ESF_FileExtAttribute</returns>
    public static ESF_FileExtAttribute ExtAttr(this enESF_UnityFileExt _ext)
    {
        return _ext.ESF_FirstAttribute<ESF_FileExtAttribute>();
    }
    #endregion
}
#endif
